#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
struct stu{
    int xuehao;
    char name[20];
    double score;
}inp[100];
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        for(int i=0; i<n; i++)
            scanf("%d%s%lf", &inp[i].xuehao, inp[i].name, &inp[i].score);
        for(int i=0; i<n; i++)
            for(int j=i; j<n; j++)
                if(inp[i].score < inp[j].score)
                {
                    struct stu tmp;
                    memcpy(&tmp, &inp[i], sizeof(inp[i]));
                    memcpy(&inp[i], &inp[j], sizeof(inp[j]));
                    memcpy(&inp[j], &tmp, sizeof(tmp));
                }
        for(int i=0; i<3; i++)
            printf("%d %s\n", inp[i].xuehao, inp[i].name);
    }
    return 0;
}